fix(mvp): repair build errors and fetch through TanStack Query #24
+222
−225
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Builds on #23. Targets
issue-6rather thanmainso that PR is green before it merges.npm run buildcurrently fails onissue-6:tsc -breports 14 errors andeslint .reports 6. This branch clears both without changing what the app is meant to do.Blocking fixes
SORT_OPTIONSwas deleted butisSortOptionstill called it, andsortwas written with an uncheckedas SortOptioncast. Restored the constant and put the validation back, so a broken value in session storage resets that one field as the comment promises.SortOptionis now onlyid-ascandid-desc. Sorting by name would mean fetching every pokemon just to learn the names, which the fetch-on-the-fly rule does not allow.GetManypushed the result offetchSafestraight into aPokemonData[], so a failed id put anullin the list and the favorites view crashed on it. It now fetches in parallel and drops the failures.matchesFiltertook one argument but was still called with two inGetPrevFilteredandGetNextFiltered. The rules are passed in as a parameter again, which also stops it re-reading session storage once per pokemon inside a loop that can run a thousand times.FavoritePokemoncalled.sort()andonSelectPokemon()on props typed as optional. They are required now, and the sort copies first instead of mutating the caller's array.PokemonCardandfilters.ts.totalwas reassigned during render, which the react-hooks rules reject. It is areducenow.Behaviour fixes
useStateand the card never remounts. It resets when the id changes.PokemonListanduseFavoritesfetched with plainuseStateanduseEffect. Both go through TanStack Query now, so the neighbours and favorites are cached instead of refetched on every click.divandliwithonClick, so neither could be reached by keyboard. They are buttons with focus outlines.Apprendered a secondid="root"inside the one inindex.html. Replaced with.app-layout.Checks
tsc -beslint .vitest runvite buildPokemonList.test.tsxwas removed in #23 and is not restored here, andGetNextFiltered/GetPrevFilteredstill have no tests. Both are covered by #10.